/*
 * @Descripttion:
 * @version:
 * @Author: lfzxs@qq.com
 * @Date: 2022-11-23 15:54:37
 * @LastEditors: lfzxs@qq.com
 * @LastEditTime: 2022-11-25 14:44:02
 */
package main

import (
	"fmt"

	"gitee.com/g_boot/gfextend/common/cfg"
)

func main() {

	expression_1 := "${GOPATH}"
	expression_2 := "${GOPATH}/fils"
	expression_3 := "${GOPATH1:home/data}/fils"
	expression_4 := "fils"

	evn_1 := map[string]interface{}{"GOPAHT": "/app/home"}

	fmt.Println(cfg.ExpandValueAnalysis(evn_1, expression_1))
	fmt.Println(cfg.ExpandValueAnalysis(evn_1, expression_2))
	fmt.Println(cfg.ExpandValueAnalysis(evn_1, expression_3))
	fmt.Println(cfg.ExpandValueAnalysis(evn_1, expression_4))

	var (
		yamlcontext = `
v_exp1: ${gopath:/app/home}
v_exp2: /files
v_exp3: ${v_exp1:/app/home}${v_exp2}/objects
# CLI.
object1:
  v_str: hello_str
  v_int: 100
  v_float: 3.14159
  v_exp3: ${v_exp1:/app/home}${v_exp2}/objects
  v_str_arr1: ['mango','apple','banana']
  v_str_arr2: ['mango','apple','${gopath:/app/home}banana']
  user1:
    name: "lee"
    age: 18
  dao:
    type: "mysql"
    ip: "192.168.21.18"
    port: 3306
vs: "hi_str"
vint: 100
vfloat: 3.15
vstr_att1: ['mysql','mssql','sqllite']
`
		data []byte = []byte(yamlcontext)
	)

	m, err := cfg.ParseYML(data)

	if err != nil {
		fmt.Println(err)
	}
	fmt.Println("YML")
	fmt.Println(m)

}
